<template>
	<view class="box" @click="godetail">
		<uni-card v-show="!show">
			<view class="info">
				<view class="top">
					<view class="title">
						{{infos.criticism_title}}
					</view>
					<view class="money">
						{{infos.money}}元/月
					</view>
					<view class="request" style="font-weight: 800;color: #000;font-size: 30rpx;">
						要求
					</view>
				</view>
				<view class="middle">
					<view class="study">
						{{study.text}}
					</view>
					<view class="work_imporance">
						{{work.text}}
					</view>
				</view>
				<view class="bottom">
					<view class="left">
						<u-avatar :src="avatar"></u-avatar>
						<view class="info">
							<view class="user_name">
								{{nickname}}
							</view>
							<view class="idcard">
							{{user_work}}
							</view>
						</view>
					</view>
					<view class="right" @click.stop="deletes">
						<u-icon  name="trash" size="25"></u-icon>
					</view>
				</view>
			</view>
		</uni-card>
		<u-skeleton
		    rows="3"
		    title
			loading
			:loading="show"
			:animate="true"
		></u-skeleton>
	</view>
</template>

<script>
	const db = uniCloud.database()
	export default {
		name: "resumeinfo",
		data() {
			return {
				show:true,
				infos:{},
				studylist: [{
						text: '高中',
						id: 0
					},
					{
						text: '中专',
						id: 1
					},
					{
						text: '大专',
						id: 2
					},
					{
						text: '本科',
						id: 3
					},
					{
						text: '硕士',
						id: 4
					},
					{
						text: '博士',
						id: 5
					},
					{
						text: '不限',
						id: 6
					}
				],
				worktimestudylist: [
					{
						text: '在校生',
						id: 0
					},
				
					{
						text: '应届生',
						id: 1
					},
					{
						text: '1年内',
						id: 2
					},
					{
						text: '1-3年内',
						id: 3
					},
					{
						text: '3-5年内',
						id: 4
					},
					{
						text: '5年以上',
						id: 5
					},
					{
						text: '不限',
						id: 6
					}
				
				]
			};
		},
		onLoad() {

		},
		computed:{
			study(){
				if(this.infos.study){
					return this.studylist[this.infos.study]
				}else{
					return this.studylist[6]
				}
			},
			work(){
				if(this.infos.work_impreance){
					return this.worktimestudylist[this.infos.work_impreance]
				}else{
						return this.worktimestudylist[6]
				}
			},
			user_work(){
				if(this.infos.user_work){
					return this.infos.user_work
				}else{
						return "人事"
				}
			},
			nickname(){
				if(this.infos.user_id){
					return this.infos.user_id[0].nickname
				}else{
					return "加载中"
				}
			},
			avatar(){
				if(this.infos.user_id){
					return this.infos.user_id[0].avatar
				}else{
					return '../../static/tx3.jpg'
				}
			}
		},
		mounted() {
			console.log(this.item, "ds")
			this.getinfo()
			console.log(this.infos.work_impreance,"供桌")
		},
		props: ['item'],
		methods: {
			//去详情页
			godetail(){
				uni.navigateTo({
					url:`/pages-other/workInfo/workInfo?_id=${this.item.recruitment_id}`
				})
			},
			deletes() {
				this.$emit("deletes",[this.item._id,this.infos.criticism_title])
				console.log('66')
			},
			async getinfo() {
				let tempinfo = db.collection("recruitment").where({
					_id: this.item.recruitment_id
				}).field("user_id,user_work,criticism_title,study,money,work_impreance").getTemp()
				let userinfo = db.collection("uni-id-users").where({
					_id: this.item.other_id
				}).field("_id,nickname,avatar").getTemp()
				
				await db.collection(tempinfo,userinfo).get().then(res=>{
					console.log('有',res)
					this.infos=res.result.data[0]
					console.log(this.infos,'ss')
					this.show=false
				})
			}

		},

	}
</script>

<style lang="scss">
	.box {

		.info {
			.top {
				display: flex;
				flex-direction: column;
				align-items: center;

				.title {
					font-weight: 800;
					font-size: 35rpx;
					color: #000;
					font-family: '楷体';
				}

				.money {
					font-weight: 600;
					font-size: 30rpx;
					color: #FFCD02;
					font-family: 'YouYuan';
				}
			}

			.middle {
				margin-top: 10rpx;
				display: flex;
				justify-content: space-around;

				view {
					background-color: #F7E7CE;
					font-size: 20rpx;
					padding: 5rpx;
					width: 100rpx;
					border-radius: 15rpx;
					text-align: center;
					margin-bottom: 20rpx;
				}

				border-bottom: 2px solid #8F8F8F;
			}

			.bottom {
				margin-top: 20rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					display: flex;

					.info {
						margin-left: 20rpx;

						.user_name {
							font-weight: 800;
							color: deeppink;
							font-size: 30rpx;
						}

						.idcard {
							color: #000;
							font-size: 25rpx;
						}
					}
				}

				.right {}
			}
		}
	}
</style>